<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>修改基金信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style type="text/css">
        body {
            background-color: #ffffff;
        }
        /* 设置下拉框宽度 */
        /* input.layui-input.layui-unselect {width:400px} */
    </style>

</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">基金代码</label>
        <div class="layui-input-block">
            <input type="hidden" name="id" id="id" value="" class="layui-input" />
            <input style="width: 400px;" type="text" name="fundNumber" lay-verify="required" lay-reqtext="基金代码不能为空" placeholder="请输入基金编号" value="" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">基金名称</label>
        <div class="layui-input-block">
            <input style="width: 400px;" type="text" name="fundName" lay-verify="required" lay-reqtext="基金名称不能为空" placeholder="请输入基金名称" value="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">基金缩写</label>
        <div class="layui-input-block">
            <input name="fundAbbrevation" style="width: 400px;" type="text" lay-verify="required" lay-reqtext="基金缩写不能为空" class="layui-input" id="test1" placeholder="请输入基金缩写">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">基金类型</label>
        <div class="layui-input-block" style="width: 400px;">
            <select id="fundType" name="fundType" class="layui-input" lay-verify="required" lay-reqtext="基金类型不能为空">
                <option value="">请选择</option>
                <option value="1">混合型</option>
                <option value="2">股票型</option>
                <option value="3">债券型</option>
                <option value="4">指数型</option>
                <option value="5">FOF型</option>
                <option value="6">QDII型</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">风险等级</label>
        <div class="layui-input-block" style="width: 400px;">
            <select id="raskRating" name="raskRating" class="layui-input" lay-verify="required" lay-reqtext="风险等级不能为空">
                <option value="">请选择</option>
                <option value="1">R1</option>
                <option value="2">R2</option>
                <option value="3">R3</option>
                <option value="4">R4</option>
                <option value="5">R5</option>
            </select>
        </div>
    </div>
    
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../js/common/constant.js"></script>
<script>
    layui.use(['form','laydate','layer'], function () {
        var laydate = layui.laydate;
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        //日期选择
        //常规用法
        // laydate.render({
        //     elem: '#test1'
        // });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url:getRootPath()+'web/fundinfo/update-info',
                type:'PUT',
                data:data.field,
                dataType:'json',
                success:function (reuslt) {
                    var index = layer.alert(reuslt.message, {
                        title: '提示信息',
                    },function () {
                    // 关闭弹出层
                    layer.close(index);
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                    if(reuslt.code==200){
                        window.parent.location.reload();
                    }
                  })
                }
            })
            return false;
        });

        /* 查询当前的基金信息 */
        $(function(){
            var url = location.search;
            var i = url.indexOf("=");
            var id = url.substring(i+1);
            $.ajax({
                url:getRootPath()+'web/fundinfo/echo',
                type:"GET",
                data:{
                    id:id
                },
                async:false,
                dataType:"json",
                success:function(data){
                    if(data.code == 200){
                        var fundInfo = data.data;
                        $("#id").val(fundInfo.id)
                        $("input[name='fundNumber']").val(fundInfo.fundNumber)
                        $("input[name='fundName']").val(fundInfo.fundName)
                        $("input[name='fundAbbrevation']").val(fundInfo.fundAbbrevation)
                        $("#fundType").val(fundInfo.fundType)
                        $("#raskRating").val(fundInfo.raskRating)
                         /*重新渲染页面*/
                        form.render();
                    }else{
                        layer.alert(data.message)
                    }
                    
                }
            })
        })
    });

</script>
</body>
</html>